<?php

namespace app\admin\controller\member;

use ShidianUtil\Thinkphp\Response\ApiResponse;
use ShidianUtil\Utils\CheckUtil;
use app\admin\model\UM as UM;
use app\admin\service\MemberWeixinService;
use think\APP;
use think\Request as Request;

/**
 * MemberWeixin 控制器
 * Class MemberWeixin
 * @package app\admin\controller\member;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\admin\validate\member\MemberWeixin
 */
class MemberWeixin
{
    // 请求参数
    private Request $request;

    // service
    private MemberWeixinService $service;

    public function __construct(Request $request, MemberWeixinService $memberWeixinService)
    {
        $this->request = $request;
        $this->service = $memberWeixinService;
    }

    /**
     * 删除
     * @param UM $user
     * @return ApiResponse
     * @url /member/member_weixin/delete
     */
    public function delete(UM $user): ApiResponse
    {
        $request     = $this->request;

        $id = $request->param('id');

        if(!CheckUtil::isId($id)){
            return ApiResponse::fail('缺少id参数');
        }

        $this->service->rm($user, $id);

        return ApiResponse::success(null);
    }
}
